'use strict';

const Controller = require('egg').Controller;
const Oss = require("ali-oss")
const ossPage = new Oss({
    accessKeyId: "LTAI5tLV7Ru1uqRj7n9zQDbx",
    accessKeySecret: "LIEnhMg4bsuA6VdwpTcHdpXyjrYPYV",
    region: "oss-cn-shanghai",
    bucket: "upalyoss",
})

const ossMpsi = new Oss({
    accessKeyId: "LTAI5tLV7Ru1uqRj7n9zQDbx",
    accessKeySecret: "LIEnhMg4bsuA6VdwpTcHdpXyjrYPYV",
    region: "oss-cn-shanghai",
    bucket: "upalympsi",
})

class HomeController extends Controller {


    async upalyoss() {
        const { ctx } = this
        const file = ctx.request.files[0]
        const filename = new Date().getTime() + file.filename
        const data = await ossPage.put(filename, file.filepath)

        ctx.body = {
            code: 1,
            msg: "图片上传",
            data
        }
    }

    async upalympsi() {
        const { ctx } = this
        const file = ctx.request.files[0]
        const filename = new Date().getTime() + file.filename
        const data = await ossMpsi.put(filename, file.filepath)

        ctx.body = {
            code: 1,
            msg: "视频上传",
            data
        }
    }



}

module.exports = HomeController;